<template>
	<view>
		<view class="hsbox">
			<view class="ershil xiaobai textcenter">总收益</view>
			<view class=" xiaobai fonweight textcenter margin_top2" style="font-size: 68rpx;">{{userInfo.total_score}}</view>
			<view class="flexbetween margin_top">
				<view class="strongtext xiaobai ">团队人数：
					<text class="ershiba xiaobai fonweight">{{userInfo.team_num}}</text>
				</view>
				<view class="strongtext xiaobai ">累计订单数：
					<text class="ershiba xiaobai fonweight">{{userInfo.order_num}}</text>
				</view>
			</view>
			<view class="flexbetween margin_top2">
				<view class="strongtext xiaobai ">邀请总数：：
					<text class="ershiba xiaobai fonweight">{{userInfo.yq_num}}</text>
				</view>
				<view class="strongtext xiaobai ">今日邀请数：
					<text class="ershiba xiaobai fonweight">{{userInfo.totay_yq_num}}</text>
				</view>
			</view>
		</view>
		<view class="mainpadding" style="position: relative;top: -80rpx;">
			<view class="ffffff radius mainpadding flexbetween">
				<view class="sanshis flexcenter">
					<view class="flexcolumn">
						<view class=" strongtext xiaohui textcenter">今日收益</view>
						<view class=" sanshier zhonghei margin_top fonweight">{{userInfo.totay_scoresy}}</view>
					</view>
				</view>
				<view class="dqline"></view>
				<view class="sanshis flexcenter">
					<view class="flexcolumn">
						<view class=" strongtext xiaohui textcenter">昨日收益</view>
						<view class=" sanshier zhonghei margin_top fonweight">{{userInfo.yestdays_scoresy}}</view>
					</view>
				</view>
				<view class="dqline"></view>
				<view class="sanshis flexcenter">
					<view class="flexcolumn">
						<view class=" strongtext xiaohui textcenter">本月收益</view>
						<view class=" sanshier zhonghei margin_top fonweight">{{userInfo.mouth_scoresy}}</view>
					</view>
				</view>
			</view>
			<view class="tab_nav margin_top2">
				<view class="navTitle" v-for="(item,index) in navList" :key="index">
					<view :class="{'active':isActive === index}" @click="checked(index)">
						{{item.title}}
					</view>
				</view>
			</view>
			<!--  我的团队-->
			<view class="" v-if="isActive==0">
				<view class="margin_top ffffff radius mainpadding" v-for="item in list.data" :key="item.id">
					<view class="flexleft">
						<image class="touxiang margin_right2" :src="item.avatar_text" mode=""></image>
						<view class="">
							<view class="ershiba fonweight">{{item.nickname}}</view>
							<view class="smalltext xiaohui margin_top1">手机号：{{item.mobile}}</view>
							<view class="smalltext xiaohui margin_top1">{{item.rec_time_text}}</view>
						</view>
					</view>
					<view class="margin_top2 huibox">
						<view class="ershil zhonghei">累计业绩：
							<text class="ershil xiaocheng">￥{{item.sy_monye}}</text>
						</view>
					</view>
				</view>
			</view>
			<!-- 收益明细 -->
			<view class="" v-if="isActive==1">
				<view class="margin_top ffffff radius mainpadding flexbetween" v-for="item in list.data" :key="item.id">
					<view class="ershiba fonweight zhonghei">{{item.createtime_text}}</view>
					<view class="titletext fonweight" style="color: #D48B39;">{{item.money}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				isActive: 0,
				navList: [{
					index: 0,
					title: '我的团队'
				}, {
					index: 1,
					title: "收益明细"
				}],
				userInfo:{},
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad() {
			this.getinfo()
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this
				let url = "/api/user/myteam"
				let data = {
					page: page || 1,
					limit: _this.limit,	
				}
				if(this.isActive==1){
					this.$set(data,"ly",1)
					url = "/api/user/scoreLog"
				}
				httpRequest.request(url, 'GET',data).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			getinfo() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			
			checked(index) {
				this.isActive = index
				this.page = 1
				this.list = {
					data:[]
				}
				this.init()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.huibox {
		padding: 20rpx 30rpx;
		background: #F1F1F1;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}
	
	.touxiang {
		width: 120rpx;
		height: 120rpx;
		border-radius: 50%;
	}
	.tab_nav {
		display: flex;
		justify-content: center;
		align-items: center;
		padding-bottom: 11rpx;
	}

	.tab_nav .navTitle {
		height: 76rpx;
		line-height: 76rpx;
		width: 100%;
		text-align: center;
		font-size: 30rpx;
		font-weight: bold;
		color: #999999;
	}

	.active {
		font-size: 30rpx;
		color: #333333;
		font-weight: bold;
		position: relative;
	}

	.active::after {
		content: "";
		position: absolute;
		width: 61rpx;
		height: 6rpx;
		background: #D48B39;
		border-radius: 9rpx;
		background-size: 100% 100%;
		left: 0rpx;
		right: 0rpx;
		bottom: 0rpx;
		margin: auto;
	}

	.dqline {
		width: 2rpx;
		height: 42rpx;
		background-color: rgba(239, 137, 51, .1);
	}

	.hsbox {
		background-color: #ff9341;
		padding: 50rpx 110rpx 80rpx;
	}
</style>